<docs>
  ##
</docs>
<template>
  <div class="index" ref="index">
    <router-view></router-view>
    <div class="bar-wrap">
      <!-- <router-link to="/person/baseInfo" class="item">求职信息</router-link> -->
      <router-link to="/position" :class="[flag_position?'_item':'item']"><!-- @click.native="publicClick('position')" -->
        <span class="position" v-show="flag_position"></span>
        <span class="position_m" v-show="!flag_position"></span>
        <p>职位</p>
      </router-link>
      <router-link to="/cv" :class="[flag_cv?'_item':'item']"><!-- @click.native="publicClick('cv')" -->
        <span class="cv" v-show="flag_cv"></span>
        <span class="cv_m" v-show="!flag_cv"></span>
        <p>简历</p>
      </router-link>
      <router-link to="/user" :class="[flag_user?'_item':'item']"> <!-- @click.native="publicClick('user')" -->
        <span class="user" v-show="flag_user"></span>
        <span class="user_m" v-show="!flag_user"></span>
        <p>我的</p>
      </router-link>
    </div>
  </div>
</template>
<script>

export default {
  name: 'index',
  data() {
    return {
      winHeight: '',
      flag_position:false,
      flag_cv:false,
      flag_user:true,
    };
  },
  methods: {
  },
  mounted() {
    // fix mobile height
    const eleHeight = this.$refs.index.offsetHeight || 0;
    const windowHeight = window.innerHeight;
    this.winHeight = `${Math.max(windowHeight, eleHeight)}px`;
  },
  watch:{
    $route:{
      handler:function(r){
        if(r.name == 'cv'){
          this.$http.get('/wdjl/jlxxCx')
          .then(res=>{
            let _res = res.returnData;
            if (+_res.executeResult == 1) {
              if(!_res.jlxx.jbxx.jzdz){
                 this.$alert({
                   type:"warning",
                   message:"请完善个人简历信息！"
                 },() => {
                this.$router.push({path:"user"})
              }) 
              }
            } else {
              this.$alert({
                type: "warning",
                message: _res.message
              });
            }
          })
        }
        this.$nextTick(_=>{
        if(r.name == 'position') {
          this.flag_position = true;
          this.flag_cv = false;
          this.flag_user = false;
        } else if (r.name == 'cv') {
          this.flag_position = false;
          this.flag_cv = true;
          this.flag_user = false;
        } else if(r.name == 'user' || r.name == 'tdlist'||r.name == 'gwlist'){
          this.flag_position = false;
          this.flag_cv = false;
          this.flag_user = true;
        } else {

        }})
      },
      immediate:true,
      deep:true
    }
  }
};
</script>
<style scoped lang="scss">
@import '~common/scss/var.scss';
.index {
  // background-color: #F4F4F4;
  // background: linear-gradient(180deg, #149dee, #246fde);
  .bar-wrap {
      span{
        display: inline-block;
        height: $height-img;
        width: $width-img;
        margin-bottom: $margin-base-small;
      }
      .position{
        background: url("~common/images/position.png") 0 0 no-repeat;
        background-size: 40px;
      }
      .position_m{
        background: url("~common/images/position_m.png") 0 0 no-repeat;
        background-size: 40px;
      }
      .user{
        background: url("~common/images/user.png") 0 0 no-repeat;
        background-size: 40px;
      }
      .user_m{
        background: url("~common/images/user_m.png") 0 0 no-repeat;
        background-size: 40px;
      }
      .cv{
        background: url("~common/images/cv.png") 0 0 no-repeat;
        background-size: 40px;
      }
      .cv_m{
        background: url("~common/images/cv_m.png") 0 0 no-repeat;
        background-size: 40px;
      }
  }

}

</style>
